Mastering Code Rewrites: How Tests Simplify Tech Debt & Architecture